#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Termstructures/VolatilityTermStructure.h>
#pragma unmanaged 
#include <ql\termstructures\volatility\optionlet\optionletvolatilitystructure.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL::Termstructures::Volatility;
using namespace Cephei::QL::Termstructures;
#define HANDLE
#define ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures { namespace Volatility { namespace Optionlet {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IOptionletVolatilityStructure
	public ref class COptionletVolatilityStructure : 
            public CVolatilityTermStructure,
            public Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletVolatilityStructure
	{
	protected: 
		boost::shared_ptr<QuantLib::OptionletVolatilityStructure>* _ppOptionletVolatilityStructure;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::OptionletVolatilityStructure>* _phOptionletVolatilityStructure;
#endif
		Object^ _OptionletVolatilityStructureOwner;     // reference to object that manages the storage for this object
	internal:
        COptionletVolatilityStructure (boost::shared_ptr<QuantLib::OptionletVolatilityStructure>& childNative, Object^ owner);
        COptionletVolatilityStructure (QuantLib::OptionletVolatilityStructure& childNative, Object^ owner);
        COptionletVolatilityStructure (COptionletVolatilityStructure^ copy);
        COptionletVolatilityStructure (System::Type^ t);
#ifdef STRUCT
        COptionletVolatilityStructure (QuantLib::OptionletVolatilityStructure childNative);
#endif       
#ifdef HANDLE
		COptionletVolatilityStructure (QuantLib::Handle<QuantLib::OptionletVolatilityStructure>& childNative, Object^ owner);
		COptionletVolatilityStructure (QuantLib::Handle<QuantLib::OptionletVolatilityStructure> childNative);
#endif
		virtual ~COptionletVolatilityStructure ();
		!COptionletVolatilityStructure ();

	internal:
		QuantLib::OptionletVolatilityStructure& GetReference ();
		boost::shared_ptr<QuantLib::OptionletVolatilityStructure>& GetShared ();
		QuantLib::OptionletVolatilityStructure* GetPointer ();
        void SetOptionletVolatilityStructure (boost::shared_ptr<QuantLib::OptionletVolatilityStructure> native)
        {
            if (_ppOptionletVolatilityStructure != NULL)
                delete _ppOptionletVolatilityStructure;
            _ppOptionletVolatilityStructure = new boost::shared_ptr<QuantLib::OptionletVolatilityStructure> (native);
            SetVolatilityTermStructure (boost::dynamic_pointer_cast<QuantLib::VolatilityTermStructure> (*_ppOptionletVolatilityStructure));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::OptionletVolatilityStructure>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Double BlackVariance (Double optionTime, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double BlackVariance (DateTime optionDate, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double BlackVariance (Cephei::QL::Times::IPeriod^ optionTenor, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Cephei::QL::Termstructures::Volatility::ISmileSection^ SmileSection (Double optionTime, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extr) ;
		virtual Cephei::QL::Termstructures::Volatility::ISmileSection^ SmileSection (DateTime optionDate, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extr) ;
		virtual Cephei::QL::Termstructures::Volatility::ISmileSection^ SmileSection (Cephei::QL::Times::IPeriod^ optionTenor, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extr) ;
		virtual Double Volatility (Double optionTime, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double Volatility (DateTime optionDate, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double Volatility (Cephei::QL::Times::IPeriod^ optionTenor, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class COptionletVolatilityStructure_Factory : public System::MarshalByRefObject,  public IOptionletVolatilityStructure_Factory
	{
	public:
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures*/ } /*Volatility*/ } /*Optionlet */}
